<?php
/* asdf
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Account
 *
 * @author eric
 */
class Account {

    function __construct() {
        //include('Util/Util.php');
        connectDB();
    }

    function CreateAccount($user, $nation) {

        $result = mysql_query("SELECT * FROM nationData");
        $row = mysql_fetch_array($result);
        $nextID = $row['maxid'] + 1;

        if(mysql_query("INSERT INTO users
            (username, id) VALUES('$user', $nextID) ")){

                    mysql_query("UPDATE nationData SET maxid=$nextID");
                    new Nation($newId, $nation);
        }else{
            return FALSE;
        }

    }

    function getID($user) {
        $result = mysql_query("SELECT * FROM users WHERE username='$user'");
        $row = mysql_fetch_array($result);
        return $row['id'];
    }

    function ifAccountExists($user) {
        $result = mysql_query("SELECT * FROM users WHERE username = '$user' ");
        return (mysql_num_rows($result) > 0) ? true : false;

    }
}
?>
